<?php namespace simpleFlow;

// Include debug
require_once(SF_LIB_DIR_ROOT.'fdebug.php');

// Include abstract object
require_once(SF_LIB_DIR_ROOT.'Object.php');

// Include file
require_once(SF_LIB_DIR_ROOT.'File.php');

// Include config
require_once(SF_LIB_DIR_ROOT.'Config.php');

// Include session
require_once(SF_LIB_DIR_ROOT.'Session.php');

/**
 * Autoload for all classes
 * @method __autoload
 * @param string $strClass Class name
 */
function __autoload($strClass)
{
	$arClass = \explode('\\', $strClass);
	$ns1 = \array_shift($arClass);
	$ns2 = \array_shift($arClass);
	
	if($ns1 == 'simpleFlow' && $ns2 == 'app')
	{
		$strInclude = \implode('/',$arClass).'.php';
		require_once(\SF_APP_DIR_ROOT.$strInclude);
	}elseif($ns1 == 'simpleFlow'){
		switch($ns2)
		{
			case 'error':
			case 'request':
			case 'database':
			case 'control':
			case 'model':
			case 'view':
				$strInclude = SF_LIB_DIR_ROOT.$ns2.'/'.\implode('/',$arClass).'.php';
				require_once($strInclude);
				break;
			default:
				trigger_error('Class not found in simpleFlow: '.$strClass);
				break;
		}
	}else{
		trigger_error('Class not found: '.$strClass);
	}
	
}

// Register autoload method with namespace
spl_autoload_register(__NAMESPACE__.'\__autoload');

?>